--- src/user.c.orig	2023-03-15 15:09:35 UTC
+++ src/user.c
@@ -407,9 +407,14 @@ user_update_from_template (User *user)
 }
 
 void
+#ifdef HAVE_SHADOW_H
 user_update_from_pwent (User          *user,
                         struct passwd *pwent,
                         struct spwd   *spent)
+#else
+user_update_from_pwent (User          *user,
+                        struct passwd *pwent)
+#endif
 {
         g_autofree gchar *real_name = NULL;
         gboolean is_system_account;
@@ -468,8 +473,10 @@ user_update_from_pwent (User          *user,
         accounts_user_set_shell (ACCOUNTS_USER (user), pwent->pw_shell);
 
         passwd = NULL;
+#ifdef HAVE_SHADOW_H
         if (spent)
                 passwd = spent->sp_pwdp;
+#endif
 
         if (passwd && passwd[0] == '!') {
                 locked = TRUE;
@@ -485,6 +492,7 @@ user_update_from_pwent (User          *user,
                 mode = PASSWORD_MODE_NONE;
         }
 
+#ifdef HAVE_SHADOW_H
         if (spent) {
                 if (spent->sp_lstchg == 0) {
                         mode = PASSWORD_MODE_SET_AT_LOGIN;
@@ -504,6 +512,9 @@ user_update_from_pwent (User          *user,
                 user->days_after_expiration_until_lock = spent->sp_inact;
                 user->account_expiration_policy_known = TRUE;
         }
+#else
+        user->user_expiration_time = g_date_time_new_from_unix_utc (pwent->pw_expire);
+#endif
 
         accounts_user_set_password_mode (ACCOUNTS_USER (user), mode);
         is_system_account = !user_classify_is_human (accounts_user_get_uid (ACCOUNTS_USER (user)),
@@ -1193,11 +1204,11 @@ user_change_real_name_authorized_cb (Daemon           
                         new_gecos = g_strdup (name);
                 }
 
-                argv[0] = "/usr/sbin/usermod";
-                argv[1] = "-c";
-                argv[2] = new_gecos;
-                argv[3] = "--";
-                argv[4] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+                argv[0] = "/usr/sbin/pw";
+                argv[1] = "usermod";
+                argv[2] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+                argv[3] = "-c";
+                argv[4] = new_gecos;
                 argv[5] = NULL;
 
                 if (!spawn_sync (argv, &error)) {
@@ -1267,11 +1278,11 @@ user_change_user_name_authorized_cb (Daemon           
                          accounts_user_get_uid (ACCOUNTS_USER (user)),
                          name);
 
-                argv[0] = "/usr/sbin/usermod";
-                argv[1] = "-l";
-                argv[2] = name;
-                argv[3] = "--";
-                argv[4] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+                argv[0] = "/usr/sbin/pw";
+                argv[1] = "usermod";
+                argv[2] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+                argv[3] = "-n";
+                argv[4] = name;
                 argv[5] = NULL;
 
                 if (!spawn_sync (argv, &error)) {
@@ -1910,7 +1921,7 @@ user_change_home_dir_authorized_cb (Daemon            
         gchar *home_dir = data;
 
         g_autoptr (GError) error = NULL;
-        const gchar *argv[7];
+        const gchar *argv[8];
 
         if (g_strcmp0 (accounts_user_get_home_directory (ACCOUNTS_USER (user)), home_dir) != 0) {
                 sys_log (context,
@@ -1919,13 +1930,14 @@ user_change_home_dir_authorized_cb (Daemon            
                          accounts_user_get_uid (ACCOUNTS_USER (user)),
                          home_dir);
 
-                argv[0] = "/usr/sbin/usermod";
-                argv[1] = "-m";
-                argv[2] = "-d";
-                argv[3] = home_dir;
-                argv[4] = "--";
-                argv[5] = accounts_user_get_user_name (ACCOUNTS_USER (user));
-                argv[6] = NULL;
+                argv[0] = "/usr/sbin/pw";
+                argv[1] = "usermod";
+                argv[2] = "-n";
+                argv[3] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+                argv[4] = "-d";
+                argv[5] = home_dir;
+                argv[6] = "-m";
+                argv[7] = NULL;
 
                 if (!spawn_sync (argv, &error)) {
                         throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message);
@@ -1977,11 +1989,11 @@ user_change_shell_authorized_cb (Daemon               
                          accounts_user_get_uid (ACCOUNTS_USER (user)),
                          shell);
 
-                argv[0] = "/usr/sbin/usermod";
-                argv[1] = "-s";
-                argv[2] = shell;
-                argv[3] = "--";
-                argv[4] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+                argv[0] = "/usr/sbin/pw";
+                argv[1] = "usermod";
+                argv[2] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+                argv[3] = "-s";
+                argv[4] = shell;
                 argv[5] = NULL;
 
                 if (!spawn_sync (argv, &error)) {
@@ -2201,9 +2213,9 @@ user_change_locked_authorized_cb (Daemon              
                          locked ? "locking" : "unlocking",
                          accounts_user_get_user_name (ACCOUNTS_USER (user)),
                          accounts_user_get_uid (ACCOUNTS_USER (user)));
-                argv[0] = "/usr/sbin/usermod";
-                argv[1] = locked ? "-L" : "-U";
-                argv[2] = "--";
+                argv[0] = "/usr/sbin/pw";
+                argv[1] = locked ? "lock" : "unlock";
+                argv[2] = "-n";
                 argv[3] = accounts_user_get_user_name (ACCOUNTS_USER (user));
                 argv[4] = NULL;
 
@@ -2281,7 +2293,7 @@ user_change_account_type_authorized_cb (Daemon        
         gsize n_extra_admin_groups_gids = 0;
         gid_t admin_gid;
         gint i;
-        const gchar *argv[6];
+        const gchar *argv[7];
 
         if (((AccountType) accounts_user_get_account_type (ACCOUNTS_USER (user))) != account_type) {
                 sys_log (context,
@@ -2328,11 +2340,11 @@ user_change_account_type_authorized_cb (Daemon        
 
                 g_free (groups);
 
-                argv[0] = "/usr/sbin/usermod";
-                argv[1] = "-G";
-                argv[2] = str->str;
-                argv[3] = "--";
-                argv[4] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+                argv[0] = "/usr/sbin/pw";
+                argv[1] = "usermod";
+                argv[2] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+                argv[3] = "-G";
+                argv[4] = str->str;
                 argv[5] = NULL;
 
                 if (!spawn_sync (argv, &error)) {
@@ -2383,7 +2395,7 @@ user_change_password_mode_authorized_cb (Daemon       
         PasswordMode mode = GPOINTER_TO_INT (data);
 
         g_autoptr (GError) error = NULL;
-        const gchar *argv[6];
+        const gchar *argv[5];
 
         if (((PasswordMode) accounts_user_get_password_mode (ACCOUNTS_USER (user))) != mode) {
                 sys_log (context,
@@ -2397,10 +2409,8 @@ user_change_password_mode_authorized_cb (Daemon       
                 if (mode == PASSWORD_MODE_SET_AT_LOGIN ||
                     mode == PASSWORD_MODE_NONE) {
                         argv[0] = "/usr/bin/passwd";
-                        argv[1] = "-d";
-                        argv[2] = "--";
-                        argv[3] = accounts_user_get_user_name (ACCOUNTS_USER (user));
-                        argv[4] = NULL;
+                        argv[1] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+                        argv[2] = NULL;
 
                         if (!spawn_sync (argv, &error)) {
                                 throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message);
@@ -2408,12 +2418,11 @@ user_change_password_mode_authorized_cb (Daemon       
                         }
 
                         if (mode == PASSWORD_MODE_SET_AT_LOGIN) {
-                                argv[0] = "/usr/bin/chage";
-                                argv[1] = "-d";
+                                argv[0] = "/usr/bin/chpass";
+                                argv[1] = "-e";
                                 argv[2] = "0";
-                                argv[3] = "--";
-                                argv[4] = accounts_user_get_user_name (ACCOUNTS_USER (user));
-                                argv[5] = NULL;
+                                argv[3] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+                                argv[4] = NULL;
 
                                 if (!spawn_sync (argv, &error)) {
                                         throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message);
@@ -2428,9 +2437,9 @@ user_change_password_mode_authorized_cb (Daemon       
                          */
                         accounts_user_set_locked (ACCOUNTS_USER (user), FALSE);
                 } else if (accounts_user_get_locked (ACCOUNTS_USER (user))) {
-                        argv[0] = "/usr/sbin/usermod";
-                        argv[1] = "-U";
-                        argv[2] = "--";
+                        argv[0] = "/usr/sbin/pw";
+                        argv[1] = "unlock";
+                        argv[2] = "-n";
                         argv[3] = accounts_user_get_user_name (ACCOUNTS_USER (user));
                         argv[4] = NULL;
 
@@ -2505,7 +2514,7 @@ user_change_password_authorized_cb (Daemon            
 
         g_autoptr (GError) error = NULL;
         g_autoptr (GSubprocess) process = NULL;
-        const char *argv[] = { "/usr/sbin/chpasswd", "-e", NULL };
+        const char *argv[] = { "/usr/bin/passwd", NULL };
 
         sys_log (context,
                  "set password and hint of user '%s' (%" G_GUINT64_FORMAT ")",
